import { http } from "@/utils/http";
import { baseUrlApi } from "./utils";

export type PageResult = {
  success: boolean;
  data: {
    /** 列表数据 */
    list: Array<any>;
    /** 总数 */
    total?: number;
  };
  errMsg: "";
};

export type DataResult = {
  success: boolean;
  data?: any;
  errMsg: "";
};

export const querySysUserList = (data?: object) => {
  return http.request<PageResult>("post", baseUrlApi("queryUserList"), {
    data
  });
};

export const updateSysUserStatus = (data?: object) => {
  return http.request<DataResult>("post", baseUrlApi("updateUserStatus"), {
    data
  });
};

export const addOrUpdateSysUser = (data?: object) => {
  return http.request<DataResult>("post", baseUrlApi("addOrUpdateUser"), {
    data
  });
};

export const deleteSysUser = (data?: object) => {
  return http.request<DataResult>("post", baseUrlApi("deleteUser"), {
    data
  });
};

export const updateUserPwd = (data?: object) => {
  return http.request<DataResult>("post", baseUrlApi("updateUserPwd"), {
    data
  });
};

export const resetSysUserPwd = (data?: object) => {
  return http.request<DataResult>("post", baseUrlApi("resetUserPwd"), {
    data
  });
};

export const querySysGroupList = (data?: object) => {
  return http.request<PageResult>("post", baseUrlApi("queryGroupList"), {
    data
  });
};

export const addOrUpdateSysGroup = (data?: object) => {
  return http.request<DataResult>("post", baseUrlApi("addOrUpdateGroup"), {
    data
  });
};

export const deleteSysGroup = (data?: object) => {
  return http.request<DataResult>("post", baseUrlApi("deleteGroup"), {
    data
  });
};

export const getSysXtSite = () => {
  return http.request<DataResult>("get", baseUrlApi("getSysXtSite"));
};

export const updateSysXtSite = (data?: object) => {
  return http.request<DataResult>("post", baseUrlApi("updateSysXtSite"), {
    data
  });
};
